package com.xybbs.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.xybbs.interceptor.LoginInterceptor;

@Configuration
public class MyConfig implements WebMvcConfigurer{

	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
		// TODO Auto-generated method stub
		registry.addViewController("/user/toSignUpPage.do").setViewName("signUp");
		registry.addViewController("/user/toLoginPage.do").setViewName("login");
		
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// TODO Auto-generated method stub
		registry.addInterceptor(new LoginInterceptor())
		.addPathPatterns("/**")
		.excludePathPatterns("/main/toMainPage.do**/**","/tip/showTip.do**/**","/user/getUserInfo.do**",
				"/user/userLogin.do","/user/toLoginPage.do",
				"/user/userSignUp.do","/user/toSignUpPage.do","/",
				"/static/**","/tip/searchTipByKeyword.do");
	}
	
	
}
